package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.AuctionUserAddress;
import com.ruoyi.demo.service.IAuctionUserAddressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户地址Controller
 *
 * @author metaee
 * @date 2025-02-24
 */
@Api(tags = "用户地址管理")
@RestController
@RequestMapping("/demo/address")
public class AuctionUserAddressController extends BaseController
{
    @Autowired
    private IAuctionUserAddressService auctionUserAddressService;

    /**
     * 查询用户地址列表
     */
    @ApiOperation("查询用户地址列表")
    @GetMapping("/list")
    public TableDataInfo list(AuctionUserAddress auctionUserAddress)
    {
        startPage();
        List<AuctionUserAddress> list = auctionUserAddressService.selectAuctionUserAddressList(auctionUserAddress);
        return getDataTable(list);
    }

    /**
     * 导出用户地址列表
     */
    @ApiOperation("导出用户地址列表")
    @Log(title = "用户地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuctionUserAddress auctionUserAddress)
    {
        List<AuctionUserAddress> list = auctionUserAddressService.selectAuctionUserAddressList(auctionUserAddress);
        ExcelUtil<AuctionUserAddress> util = new ExcelUtil<AuctionUserAddress>(AuctionUserAddress.class);
        util.exportExcel(response, list, "用户地址数据");
    }

    /**
     * 获取用户地址详细信息
     */
    @ApiOperation("获取用户地址详细信息")
    @GetMapping(value = "/{addressId}")
    public AjaxResult getInfo(@PathVariable("addressId") Long addressId)
    {
        return success(auctionUserAddressService.selectAuctionUserAddressByAddressId(addressId));
    }

    /**
     * 新增用户地址
     */
    @ApiOperation("新增用户地址")
    @Log(title = "用户地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionUserAddress auctionUserAddress)
    {
        return toAjax(auctionUserAddressService.insertAuctionUserAddress(auctionUserAddress));
    }

    /**
     * 修改用户地址
     */
    @ApiOperation("修改用户地址")
    @Log(title = "用户地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionUserAddress auctionUserAddress)
    {
        return toAjax(auctionUserAddressService.updateAuctionUserAddress(auctionUserAddress));
    }

    /**
     * 删除用户地址
     */
    @ApiOperation("删除用户地址")
    @Log(title = "用户地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{addressIds}")
    public AjaxResult remove(@PathVariable Long[] addressIds)
    {
        return toAjax(auctionUserAddressService.deleteAuctionUserAddressByAddressIds(addressIds));
    }
}
